package com.yindian.cos.easy.security.authentication.token;

import com.yindian.cos.easy.security.authentication.login.UserDetail;
import com.yindian.cos.easy.security.properties.TokenProperties;
import lombok.Data;

/**
 * token生成工厂的抽象
 *
 * @author zhangchuanhao
 * @create 2018/11/21
 */
@Data
public abstract class AbstractTokenFactory {

    private TokenStore tokenStore;

    private TokenProperties tokenProperties;

    public AbstractTokenFactory(TokenStore tokenStore, TokenProperties tokenProperties) {
        this.tokenStore = tokenStore;
        this.tokenProperties = tokenProperties;
    }

    /**
     * 生成token的抽象方法
     *
     * @param userDetail
     * @return
     */
    public abstract Token builder(UserDetail userDetail);

    /**
     * 刷新token的抽象方法
     *
     * @param refreshToken
     * @return
     */
    public abstract Token refresh(String refreshToken);

    /**
     * 删除token
     *
     * @param accessToken
     * @return
     */
    public abstract boolean remove(String accessToken);
}
